package com.example.mobile2030606148tdh0330;

import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Switch;

import androidx.appcompat.app.AppCompatActivity;

public class MainActivity extends AppCompatActivity {

    private Button btnMainLogin;
    private Button btnMainReset;
    private EditText edtTextAccout;
    private EditText edtTextPsw;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initView();
        btnMainLogin.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //获取输入内容
                String account=edtTextAccout.getText().toString();
                String password=edtTextPsw.getText().toString();

            //输入不完整的判断
               if (account.length()==0){
                   Log.i("登录","请输入用户名");

               }else if(password.length()==0){
                    Log.i("登录","请输入密码");
                }else{


                }









            //判断
                if(account.equals("admin")&password.equals("123456")){
                    Log.i("登录","登陆成功");
                }else{
                    Log.i("登录","登陆失败");
                }
                edtTextAccout.setText(null);
                edtTextPsw.setText(null);






            }
        });
        //重置
      btnMainReset.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View v) {
              edtTextAccout.setText(null);
              edtTextPsw.setText(null);
          }
      });

    }

    private void initView() {
        edtTextAccout = (EditText) findViewById(R.id.edtText_accout);
        edtTextPsw = (EditText) findViewById(R.id.edtText_psw);
        btnMainLogin=(Button)findViewById(R.id.btn_main_login);
        btnMainReset=(Button)findViewById(R.id.btn_main_reset);
    }
}


